# Maintainer: Kyle Keen <keenerd@gmail.com>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Contributor: Jelle van der Waa <jelle@vdwaa.nl>
# Contributor: Pierre Chapuis <catwell@archlinux.us>
# Contributor: Stefano Esposito <ragnarok@email.it>

pkgname=python-irc
pkgver=20.1.0
pkgrel=2
pkgdesc="IRC (Internet Relay Chat) protocol client library for Python"
arch=('any')
url="https://pypi.python.org/pypi/irc"
license=(MIT)
depends=(
  python-jaraco.collections
  python-jaraco.functools
  python-jaraco.logging
  python-jaraco.stream
  python-jaraco.text
  python-more-itertools
  python-pytz
  python-tempora
)
makedepends=('python-build' 'python-installer' 'python-setuptools-scm' 'python-wheel')
checkdepends=(python-pytest python-pytest-enabler python-pygments)
source=("https://files.pythonhosted.org/packages/source/i/irc/irc-$pkgver.tar.gz")
sha256sums=('b6f737932dd4791f3b18e319de7b7daf02d2285a6bea263d101f4d8e553807ec')

build() {
  cd "irc-$pkgver"
  python -m build --wheel --no-isolation
}

check() {
  cd "irc-$pkgver"
  pytest -vv -c /dev/null
}

package() {
  cd "irc-$pkgver"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 *.rst -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 scripts/*.py -t "$pkgdir/usr/share/doc/$pkgname/scripts/"

  # Remove sample scripts installed in generic namespace
  # TODO: report upstream!
  rm -r "$pkgdir"/usr/lib/python*/site-packages/scripts
}
